--[[	$Id: battleground.lua 2364 2011-12-05 21:32:31Z sdkyron@gmail.com $	]]

local _, caelCore = ...

caelCore.battleground = caelCore.createModule("Battleground")

local battleground = caelCore.battleground

--[[	Auto release in battleground	]]

battleground:SetScript("OnEvent", function(self, event)
	if event == "PLAYER_DEAD" then
		local _, instanceType = IsInInstance()
		if instanceType == "pvp" or tostring(GetZoneText()) == "Wintergrasp" or tostring(GetZoneText()) == "Tol Barad" then
			RepopMe()
		end
	elseif event == "UPDATE_BATTLEFIELD_STATUS" then
		if	StaticPopup_Visible("CONFIRM_BATTLEFIELD_ENTRY") then
			UIFrameFlash(caelCoreModuleShadowEdge and caelCoreModuleShadowEdge or LowHealthFrame, 0.2, 0.2, 0.4, caelCoreModuleShadowEdge and true or false, 0, 0.2)
			PlaySoundFile([=[Sound\Interface\ReadyCheck.wav]=], "Master")
		end
	end
end)

for _, event in next, {
	"PLAYER_DEAD",
	"UPDATE_BATTLEFIELD_STATUS"
} do
	battleground:RegisterEvent(event)
end